package com.rizzo.android.domain;

import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;

@DatabaseTable(tableName = Error.TABLE_NAME)
public class Error implements Serializable {

	public static final String TABLE_NAME = "error";
	public static final String ID_FIELD = "_id";
	public static final String APPLICATION_FIELD = "application";
	public static final String TOTAL_USERS_FIELD = "total_users";
	public static final String APPLICATION_INDEX = "application_idx";
	public static final String[] AVAILABLE_FIELDS = {ID_FIELD, APPLICATION_FIELD, TOTAL_USERS_FIELD};

	@DatabaseField(id = true, columnName = ID_FIELD, generatedId = true)
	private long id;

	@DatabaseField(canBeNull = false, columnName = APPLICATION_FIELD, index = true, indexName = APPLICATION_INDEX)
	private String application;

	@DatabaseField(canBeNull = false, columnName = TOTAL_USERS_FIELD)
	private long totalUsers;

	@ForeignCollectionField(eager = false)
	private ForeignCollection<ErrorData> errorData;

	public Error() {
	}

	public Error(String application, long totalUsers) {
		this.application = application;
		this.totalUsers = totalUsers;
	}

	public String getApplication() {
		return application;
	}

	public void setApplication(String application) {
		this.application = application;
	}

	public ForeignCollection<ErrorData> getErrorData() {
		return errorData;
	}

	public void setErrorData(ForeignCollection<ErrorData> errorData) {
		this.errorData = errorData;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getTotalUsers() {
		return totalUsers;
	}

	public void setTotalUsers(long totalUsers) {
		this.totalUsers = totalUsers;
	}
}
